//Java script document

var toChange = "";


$(document).ready(function() {
  $('#manageaccount').hide();
  $('#usernameChange,#f_nameChange,#l_nameChange,#emailaddressChange,#passwordChange').hover(
			function() {
				$(this).animate({"opacity": "0.25"}, "slow");
			},
			function() {
				$(this).animate({"opacity": "1"}, "slow");	
			}
	);
	 
	 
   $('#usernameChange,#f_nameChange,#l_nameChange,#emailaddressChange,#passwordChange').click(function(){
		$('#manageaccount').hide('slow');
    if( $(this).attr("alt") == $('#usernameChange').attr("alt") ) toChange = 'username';  
		if( $(this).attr("alt") == $('#f_nameChange').attr("alt") ) toChange = 'f_name';
		if( $(this).attr("alt") == $('#l_nameChange').attr("alt") ) toChange = 'l_name';
		if( $(this).attr("alt") == $('#emailaddressChange').attr("alt") ) toChange = 'emailaddress';						   
		if( $(this).attr("alt") == $('#passwordChange').attr("alt") ) toChange = 'password';  
  	$('#manageaccount').show('slow');
	});
   
	$('#changeSubmit').click(function(){
	
		if( $('#changeInput').val().length > 0){
			//alert($('#user_name').html());
			$.post("manage_account.php", {username: ""+$('#username').html()+"" , change: ""+toChange+"" , value: ""+$('#changeInput').val()+"" }, function(data){
				if(data.length >0) {
					//alert(data);
				}
				});
			var s = "#"+toChange;
			$(s).fadeOut("slow");
			$(s).html($('#changeInput').val());
			$(s).fadeIn("slow");
  	}
		else{
			//do nothing	
		}		   			   
	});
	
	
	
	
 });
